<?php /* УТФ-8:fix */

class SPI
{
    static private $instances = array();

    static public function I( $module_id )
    {
        if( isset( self::$instances[$module_id] ) === false )
        {
            $classname = "SPIcore__{$module_id}";

            if( class_exists( $classname ) === false )
            {
                return false;
            }

            self::$instances[$module_id] = new $classname;
        }

        return self::$instances[$module_id];
    }
}

class SPI__dummy
{
    protected $subobjects_buffer = array();

    public function __get( $varname )
    {
        $classname = get_class( $this ) . "__{$varname}";

        if( isset($this->subobjects_buffer[$classname])===false || is_object( $this->subobjects_buffer[$classname] ) === false )
        {
            if( class_exists( $classname ) === false )
            {
                return null;
            }

            $this->subobjects_buffer[$classname] = new $classname;
        }

        return $this->subobjects_buffer[$classname];
    }
}
